#include <iostream>
#include <vector>
using namespace std;

vector<int> path;
void show_path(){
        for(auto v : path){
                cout << v << " ";
        }
        cout << path[0] << endl;
}

int dfs(vector<vector<int>> &gh, vector<int> &vis, int u, int start, int len, int &cnt)
{
        vis[u] = 1;
        path.push_back(u);
        for(auto v : gh[u]){
                if(v == start && len >= 2){
                        show_path();
                        cnt++;
                }
                if(v > start && !vis[v]){
                        dfs(gh, vis, v, start , len + 1, cnt);
                }
        }
        path.pop_back();
        vis[u] = 0;
}

int main()
{
        int n, m;
        cin >> n >> m;
        vector<vector<int>> gh(n + 1);

        for(int i = 0; i < m; i++){
                int u, v;
                cin >> u >> v;
                gh[u].push_back(v);
                gh[v].push_back(u);
        }

        int cnt = 0;
        vector<int> vis(n + 1, 0);
        for(int u = 1; u <= n; u++){
                vis[u] = 1;
                path.push_back(u);
                for(auto v : gh[u]){
                        if(v > u){
                                dfs(gh, vis, v, u, 1, cnt);                        
                        }
                }
                path.pop_back();
                vis[u] = 0;
        }

        cout << cnt/2 << endl;
        return 0;
}